<?php


namespace app\common\model;


use app\common\enum\MainEnum;

class OrderListModel extends CommonModel
{
    protected $name = 'order_list';

    public function getPriceDiscountDescAttr($v)
    {
        return json_decode($v, true);
    }

    public function setPriceDiscountDescAttr($v)
    {
        return json_encode($v, JSON_UNESCAPED_UNICODE);
    }

    public function setPackageFhTimeAttr($v)
    {
        return date('Y-m-d H:i:s', $v);
    }

    public function getExtendStatusTextAttr($v, $data): ?string
    {
        return OrderListRefundModel::getOrderListRefundStatusText($data['status']);
    }

    public function refundInfo(): \think\model\relation\HasMany
    {
        return $this->hasMany(OrderListRefundModel::class, 'order_list_id', 'id');
    }
}